package com.chuantou.yuba.api.to;

import java.util.ArrayList;
import java.util.List;

import android.os.Parcel;
import android.os.Parcelable;

import com.google.gson.annotations.SerializedName;

/**
 * 单条动态
 * 
 * @author dl1001
 * 
 */
public class TrendsTO implements Parcelable {
	// id
	@SerializedName("id")
	private Long id;
	// 发送动态用户id
	@SerializedName("uid")
	private Long uid;
	// 动态文字内容
	@SerializedName("content")
	private String content;
	// 发送动态地理位置
	@SerializedName("address")
	private String address;
	// 发送动态时间
	@SerializedName("dateline")
	public Long sendTime;
	// 被赞次数
	@SerializedName("like_total")
	private Integer likeCount;
	// 发送动态用户昵称
	@SerializedName("username")
	private String nickname;
	// 发送动态用户性别
	@SerializedName("sex")
	private int sex;
	// 头像
	@SerializedName("avatar")
	private String avatar;
	// 发送者动态
	@SerializedName("birthday")
	private String birthday;
	// 图片
	@SerializedName("img_list")
	private List<TrendsImageTO> images;

	// 评论总数
	@SerializedName("reply_total")
	private int commentCount;

	// 评论列表
	@SerializedName("reply_list")
	private List<TrendsCommentTO> comments;
	// 是否已经喜欢
	@SerializedName("like")
	private int like;

	@SerializedName("distance")
	private double distance;

	public TrendsTO() {
	}

	public TrendsTO(Parcel source) {
		// TODO 需要序列化时再做
	}

	@Override
	public int describeContents() {
		return 0;
	}

	public boolean isLike() {
		return like == 1;
	}

	public void setHasLiked(boolean like) {
		this.like = like ? 1 : 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		// TODO 需要序列化时再做
	}

	public static final Creator<TrendsTO> CREATOR = new Creator<TrendsTO>() {

		@Override
		public TrendsTO[] newArray(int size) {
			return new TrendsTO[size];
		}

		@Override
		public TrendsTO createFromParcel(Parcel source) {
			return new TrendsTO(source);
		}
	};

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getUid() {
		return uid == null ? 0 : uid;
	}

	public void setUid(Long uid) {
		this.uid = uid;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public Long getSendTime() {
		return sendTime;
	}

	public void setSendTime(Long sendTime) {
		this.sendTime = sendTime;
	}

	public Integer getLikeCount() {
		return likeCount;
	}

	public void setLikeCount(Integer likeCount) {
		this.likeCount = likeCount;
		if (this.likeCount < 0) {
			this.likeCount = 0;
		}
	}

	public String getNickname() {
		return nickname;
	}

	public void setNickname(String nickname) {
		this.nickname = nickname;
	}

	public int getSex() {
		return sex;
	}

	public void setSex(int sex) {
		this.sex = sex;
	}

	public String getAvatar() {
		return avatar;
	}

	public void setAvatar(String avatar) {
		this.avatar = avatar;
	}

	public List<TrendsImageTO> getImages() {
		return images;
	}

	public void setImages(List<TrendsImageTO> images) {
		this.images = images;
	}

	public List<TrendsCommentTO> getComments() {
		return comments;
	}

	public void addComment(TrendsCommentTO comment) {
		if (this.comments == null) {
			this.comments = new ArrayList<TrendsCommentTO>();
		}
		this.comments.add(comment);
	}

	public void setComments(List<TrendsCommentTO> comments) {
		this.comments = comments;
	}

	public String getBirthday() {
		return birthday;
	}

	public void setBirthday(String birthday) {
		this.birthday = birthday;
	}

	public int getLike() {
		return like;
	}

	public void setLike(int like) {
		this.like = like;
	}

	public int getCommentCount() {
		return commentCount;
	}

	public void setCommentCount(int commentCount) {
		this.commentCount = commentCount;
	}

	public double getDistance() {
		return distance;
	}

	public void setDistance(double distance) {
		this.distance = distance;
	}

}
